package com.ny.view;


import com.ny.entity.Student;
import com.ny.service.Impl.StudentServiceImpl;
import com.ny.service.StudentService;

import java.sql.SQLException;
import java.util.Scanner;

public class ReguserView {
    private StudentService ser1 = new StudentServiceImpl();

    public ReguserView() throws SQLException, ClassNotFoundException {
    }

    public void showRegisterForm() {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入用户名：");
        String username = scanner.next();

        System.out.println("请输入密码：");
        String pwd = scanner.next();

        System.out.println("请输入手机号：");
        String phone = scanner.next();

        Student stud1 = new Student();
        stud1.setStudentName(username);
        stud1.setStudentPassword(pwd);
        stud1.setStudentPhone(phone);

        try {
            ser1.addStudent(stud1);
            System.out.println("注册成功");
        } catch (Exception e) {
            System.out.println("注册失败: " + e.getMessage());
            e.printStackTrace();

        }
    }
}
